package org.quartz.ui.web.action.definitions;

import java.util.Map;

import org.quartz.ui.web.action.base.BaseAction;
import org.quartz.ui.web.model.JobDefinition;

/**
 * @author zhurx4g@gmail.com
 */
public class Load extends BaseAction {

	/**
     * 
     */
	private static final long serialVersionUID = -8789546841183859383L;
	private String definitionName;
	JobDefinition _definition = new JobDefinition();

	@Override
	public String execute() {

		if (definitionName == null || definitionName.length() < 1) {
			// this is fine. No definition loaded(new)
			return INPUT;
		} else {

			_definition = BaseAction.getDefinitionManager().getDefinition(
					definitionName);

			return SUCCESS;
		}

	}

	public Map getDefinitions() {
		return getDefinitionManager().getDefinitions();
	}

	public String list() {
		return SUCCESS;
	}

	/**
	 * @return
	 */
	public JobDefinition getDefinition() {
		return _definition;
	}

	/**
	 * @return
	 */
	public void setDefinitionName(String definitionName) {
		this.definitionName = definitionName;
	}

}
